package org.endy.leisure.diaTracker.service

import org.endy.leisure.diaTracker.entity.User
import org.endy.leisure.diaTracker.entity.question.Image
import org.endy.leisure.diaTracker.entity.question.Question
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class QuestionServiceTest {

    @Autowired
    private lateinit var questionService: QuestionService

    private val userId = "1234554321"

    private val user = User(id = userId)

    @Test
    fun createQuestion() {
        val q = Question(
            content = "最近测量血压总是很不稳定",
            user = user,
            images = listOf(Image(url = "image/1.png", order = 0), Image(url = "image/2.png", order = 1))
        )
        questionService.createQuestion(q)
    }

    @Test
    fun findUserQ() {
        val q = questionService.findUserQ(userId).get(0)
        print(q)
        assertEquals("最近测量血压总是很不稳定", q.content)
        assertEquals(0, q.images?.get(1)?.order)
    }

    @Test
    fun answerQ() {
        questionService.answerQ(1,userId,"这个可能是由于情绪不稳定导致的")
    }

}